<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.16"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>AngelScript: file</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
  $(document).ready(initResizable);
/* @license-end */</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
  $(document).ready(function() { init_search(); });
/* @license-end */
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="aslogo_small.png"/></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">AngelScript
   </div>
  </td>
   <td>        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
</td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.16 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search');
/* @license-end */
</script>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(document).ready(function(){initNavTree('doc_script_stdlib_file.html','');});
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="PageDoc"><div class="header">
  <div class="headertitle">
<div class="title">file </div>  </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><dl class="section note"><dt>Note</dt><dd>file is only available in the scripts if the application <a class="el" href="doc_addon_file.html">registers support for it</a>.</dd></dl>
<p>Script example:</p>
<pre>
  file f;
  // Open the file in 'read' mode
  if( f.open("file.txt", "r") &gt;= 0 ) 
  {
      // Read the whole file into the string buffer
      string str = f.readString(f.getSize()); 
      f.close();
  }
</pre><h1><a class="anchor" id="doc_script_stdlib_file_1"></a>
Supporting file object</h1>
<h2><a class="anchor" id="doc_script_stdlib_file_1_1"></a>
Methods</h2>
<p><b>int open(const string &amp;in filename, const string &amp;in mode)</b><br  />
</p>
<p>Opens a file. The mode can be "r" for reading, "w" for writing, or "a" for appending.</p>
<p>If the file couldn't be opened, a negative value is returned.</p>
<p><b>int close()</b><br  />
</p>
<p>Closes the file.</p>
<p>If no file is open, a negative value is returned.</p>
<p><b>int getSize() const</b><br  />
</p>
<p>Returns the size of the file, or a negative value if no file is open.</p>
<p><b>bool isEndOfFile() const</b><br  />
</p>
<p>Returns true if the current position is at the end of the file.</p>
<p><b>string readString(uint length)</b><br  />
</p>
<p>Reads <em>length</em> bytes into a string and returns it.</p>
<p><b>string readLine()</b><br  />
</p>
<p>Reads until a new line character, e.g. '\n', or end-of-file and returns the string. The new line character is also returned in the string.</p>
<p><b>int64 readInt(uint bytes)</b><br  />
</p>
<p>Reads <em>bytes</em> as a signed integer number.</p>
<p><b>uint64 readUInt(uint bytes)</b><br  />
</p>
<p>Reads <em>bytes</em> as an unsigned integer number.</p>
<p><b>float readFloat()</b><br  />
</p>
<p>Reads 4 bytes as a float number.</p>
<p><b>double readDouble()</b><br  />
</p>
<p>Reads 8 bytes as a double number.</p>
<p><b>int writeString(const string &amp;in str)</b><br  />
</p>
<p>Writes the bytes of the string into the file.</p>
<p>Returns the number of bytes written, or a negative value on error.</p>
<p><b>int writeInt(int64 value, uint bytes)</b><br  />
</p>
<p>Writes <em>bytes</em> as a signed integer value.</p>
<p>Returns the number of bytes written, or a negative value on error.</p>
<p><b>int writeUInt(uint64 value, uint bytes)</b><br  />
</p>
<p>Writes <em>bytes</em> as an unsigned integer value.</p>
<p>Returns the number of bytes written, or a negative value on error.</p>
<p><b>int writeFloat(float value)</b><br  />
</p>
<p>Writes 4 bytes as a float value.</p>
<p>Returns the number of bytes written, or a negative value on error.</p>
<p><b>int writeDouble(double value)</b><br  />
</p>
<p>Writes 8 bytes as a double value.</p>
<p>Returns the number of bytes written, or a negative value on error.</p>
<p><b>int getPos() const</b><br  />
</p>
<p>Returns the current position in the file, or a negative value on error.</p>
<p><b>int setPos(int pos)</b><br  />
</p>
<p>Sets the current position in the file. Returns the previous position or a negative value on error.</p>
<p><b>int movePos(int delta)</b><br  />
</p>
<p>Moves the position <em>delta</em> bytes relative to the current position. Returns the previous position or a negative value on error.</p>
<h2><a class="anchor" id="doc_script_stdlib_file_1_2"></a>
Properties</h2>
<p><b>bool mostSignificantByteFirst</b><br  />
</p>
<p>This property should be set to true if the most significant bit should be read or written first in the methods that reads/writes numbers.</p>
<p>It is set to false by default, which is the standard on most platforms. </p>
</div></div><!-- contents -->
</div><!-- PageDoc -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="footer">Generated on Sun Sep 22 2019 11:47:56 for AngelScript by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.16 </li>
  </ul>
</div>
</body>
</html>
